import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";

export const Layout = () => import("@/layout/index.vue");

// 静态路由
export const constantRoutes: RouteRecordRaw[] = [
  {
    path: "/redirect",
    component: Layout,
    meta: { hidden: true },
    children: [
      {
        path: "/redirect/:path(.*)",
        component: () => import("@/views/redirect/index.vue"),
      },
    ],
  },

  {
    path: "/login",
    component: () => import("@/views/login/index.vue"),
    meta: { hidden: true },
  },

  {
    path: "/",
    name: "/",
    component: Layout,
    redirect: "/adGroup",
    meta: { title: '控制面板', icon: 'homepage', hidden: true },
    children: [
      // {
      //   path: "dashboard",
      //   meta: { title: '分析页', icon: 'chart', affix: true, keepAlive: true, },
      //   component: () => import("@/views/dashboard/dashboard.vue"),
      //   name: "Dashboard", // 用于 keep-alive, 必须与SFC自动推导或者显示声明的组件name一致
      //   // https://cn.vuejs.org/guide/built-ins/keep-alive.html#include-exclude
      // },
      // {
      //   path: "/analysis",
      //   name: "Analysis",
      //   component: () => import("@/views/dashboard/statistics.vue"),
      //   meta: { title: "代理统计", icon: "dashboard" },
      // },
      {
        path: "401",
        component: () => import("@/views/error-page/401.vue"),
        meta: { hidden: true },
      },
      {
        path: "404",
        component: () => import("@/views/error-page/404.vue"),
        meta: { hidden: true },
      },
    ],
  },
  // {
  //   path: "/vipAdmin",
  //   component: Layout,
  //   redirect: "/UserAdmin",
  //   meta: { title: '会员管理', icon: 'vip' },
  //   children: [
  //     {
  //       path: "/userAdmin",
  //       name: "UserAdmin",
  //       component: () => import("@/views/vipAdmin/userAdmin.vue"),
  //       meta: { title: "用户列表", icon: "peoples" },
  //     },
  //     {
  //       path: "/setwallet",
  //       name: "Setwallet",
  //       component: () => import("@/views/vipAdmin/setwallet.vue"),
  //       meta: { title: "钱包设置", icon: "wallet" },
  //     }
  //   ]
  // },
  // {
  //   path: "/product",
  //   component: Layout,
  //   redirect: "/product",
  //   meta: { title: '产品管理', icon: 'tree' },
  //   children: [
  //     {
  //       path: "/productList",
  //       name: "ProductList",
  //       component: () => import("@/views/product/list.vue"),
  //       meta: { title: "产品列表", icon: "multi_level" },
  //     },
  //     {
  //       path: "/order",
  //       name: "Order",
  //       component: () => import("@/views/product/order.vue"),
  //       meta: { title: "订单列表", icon: "brand" },
  //     }
  //   ]
  // },
  // {
  //   path: "/capitalAdmin",
  //   component: Layout,
  //   redirect: "/recharge",
  //   meta: { title: '资金管理', icon: 'capital' },
  //   children: [
  //     {
  //       path: "/recharge",
  //       name: "Recharge",
  //       component: () => import("@/views/transaction/recharge.vue"),
  //       meta: { title: "会员充值", icon: "masonry" },
  //     },
  //     {
  //       path: "/withdraw",
  //       name: "Withdraw",
  //       component: () => import("@/views/transaction/withdraw.vue"),
  //       meta: { title: "提现审核", icon: "withdrawal" },
  //     },
  //     {
  //       path: "/transaction",
  //       name: "Transaction",
  //       component: () => import("@/views/transaction/transaction.vue"),
  //       meta: { title: "资金明细", icon: "detail" },
  //     },
  //     {
  //       path: "/bank",
  //       name: "Bank",
  //       component: () => import("@/views/transaction/bank.vue"),
  //       meta: { title: "链路管理", icon: "chain" },
  //     },
  //     {
  //       path: "/coindata",
  //       name: "Coindata",
  //       component: () => import("@/views/transaction/coindata.vue"),
  //       meta: { title: "币种管理", icon: "coindata" },
  //     }
  //   ]
  // },
  // {
  //   path: "/product",
  //   component: Layout,
  //   redirect: "/product",
  //   meta: { title: '内容管理', icon: 'homepage' },
  //   children: [
  //     {
  //       path: "/productList",
  //       name: "Product",
  //       component: () => import("@/views/product/list.vue"),
  //       meta: { title: "文章管理", icon: "homepage" },
  //     }
  //   ]
  // },
  // {
  //   path: "/roleAdmin",
  //   component: Layout,
  //   redirect: "/admin",
  //   meta: { title: '权限管理', icon: 'peoplesAdmin' },
  //   children: [
  //     {
  //       path: "/admin",
  //       name: "Admin",
  //       component: () => import("@/views/system/admin.vue"),
  //       meta: { title: "管理员", icon: "role" },
  //     },
  //     {
  //       path: "/role",
  //       name: "Role",
  //       component: () => import("@/views/system/role.vue"),
  //       meta: { title: "角色管理", icon: "peoples" },
  //     },
  //     {
  //       path: "/menu",
  //       name: "Menu",
  //       component: () => import("@/views/system/menu/index.vue"),
  //       meta: { title: "路由", icon: "lang" },
  //     }
  //   ]
  // },
  // {
  //   path: "/system",
  //   component: Layout,
  //   redirect: "/config",
  //   meta: { title: '系统配置', icon: 'system' },
  //   children: [
  //     {
  //       path: "/config",
  //       name: "Config",
  //       component: () => import("@/views/config/config.vue"),
  //       meta: { title: "参数配置", icon: "set" },
  //     },
  //     {
  //       path: "/lang",
  //       name: "Lang",
  //       component: () => import("@/views/config/lang.vue"),
  //       meta: { title: "语言设定", icon: "lang" },
  //     }
  //   ]
  // },
];

/**
 * 创建路由
 */
const router = createRouter({
  history: createWebHashHistory(),
  routes: constantRoutes as RouteRecordRaw[],
  // 刷新时，滚动条位置还原
  scrollBehavior: () => ({ left: 0, top: 0 }),
});

/**
 * 重置路由
 */
export function resetRouter() {
  router.replace({ path: "/login" });
}

export default router;
